package com.ygo.feihua.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import cn.bmob.v3.datatype.BmobFile;
import com.ygo.feihua.Gongju;
import com.ygo.feihua.R;
import java.util.List;
import android.view.View.OnClickListener;
import android.content.Intent;
import com.ygo.feihua.ImageXiangxi;

public class AdapterImageview extends BaseAdapter
{

	List<BmobFile> data;
	Context context;
	Zujian zujian;
	Gongju gj;
	
	public AdapterImageview(Context context,List<BmobFile> data){
		this.context=context;
		this.data=data;
		gj=Gongju.getdx(context);
	}
	
	class Zujian{
		ImageView ii_image;
	}
	
	@Override
	public int getCount()
	{
		// TODO: Implement this method
		return data.size();
	}

	@Override
	public Object getItem(int p1)
	{
		// TODO: Implement this method
		return data.get(p1);
	}

	@Override
	public long getItemId(int p1)
	{
		// TODO: Implement this method
		return p1;
	}

	@Override
	public View getView(final int position, View p2, ViewGroup p3)
	{
		if(p2==null){
			zujian=new Zujian();
			p2=LayoutInflater.from(context).inflate(R.layout.item_image,null);
			
			zujian.ii_image=(ImageView) p2.findViewById(R.id.ii_image);
			p2.setTag(zujian);
		}else{
			zujian=(Zujian)p2.getTag();
		}
		gj.tuxian(data.get(position).getFileUrl(),zujian.ii_image);
		zujian.ii_image.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View p1)
				{
					Intent intent1 =new Intent(context,ImageXiangxi.class);
					intent1.putExtra("uri",data.get(position).getFileUrl());
					context.startActivity(intent1);
					// TODO: Implement this method
				}
			});
		
		
		// TODO: Implement this method
		return p2;
	}
	
	
	
}
